#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;
const int N = 1010;
int n, h, r, T;
int p[N], minp[N], maxp[N];
struct Node
{
    int x, y, z;
}zb[N];
double get(Node& a, Node& b)
{
    ll dx = a.x - b.x, dy = a.y - b.y, dz = a.z - b.z;
    return sqrt(dx * dx + dy * dy + dz * dz);
}
int find(int x)
{
    if (x != p[x]) p[x] = find(p[x]);
    return p[x];
}
int main()
{
    cin >> T;
    while (T--)
    {
        cin >> n >> h >> r;
        for (int i = 1; i <= n; i++)
        {
            cin >> zb[i].x >> zb[i].y >> zb[i].z;
        }

        for (int i = 1; i <= n; i++)
        {
            p[i] = i;
            minp[i] = zb[i].z;
            maxp[i] = zb[i].z;
        }
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                if (get(zb[i], zb[j]) <= 2 * r)
                {
                    int pa = find(i), pb = find(j);
                    if (pa != pb)
                    {
                        p[pa] = pb;
                        minp[pb] = min(minp[pa], minp[pb]);
                        maxp[pb] = max(maxp[pa], maxp[pb]);
                    }
                }
            }
        }
        int i = 1;
        for (; i <= n; i++)
        {
            int pa = find(i);
            if (maxp[pa] + r >= h && minp[pa] - r <= 0)
            {
                cout << "Yes" << endl;
                break;
            }
        }
        if (i > n) cout << "No" << endl;
    }
    return 0;
}